<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">短剧管理</a>
            <a><cite>设置固定剧集</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <table id="other" lay-filter="other"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        let params = {
            elem: '#other'
            , toolbar: '#toolbarDemo'
            , url: '/admin/other/list' //数据接口
            , id: 'other'
            ,page:true
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 80}
                , { field: 'admin_uid', title: '发布者用户ID', }
                , { field: 'admin_user_name', title: '发布者用户名称', }
                , {
                    field: 'created_at', title: '短剧名称', templet: function (d) {
                        let tem = ``
                        // 
                        d.video_id.forEach(v=>{
                            tem+= `<span class="layui-badge layui-bg-green" style='margin-right:5px'>${v.name}</span>`
                        })
                        return tem
                    }
                }
                
                , { toolbar: '#tbBar', title: '操作', width: 150 }
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(other)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加', './info.html', 650, 600);
                }
            });
            table.on('tool(other)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    DeleteAjax('/admin/other/delete',{ id: obj.data.id },'other')
                } else if (event === 'edit') {
                    x_admin_show('编辑', `./info.html?id=${obj.data.id}`, 650, 600);
                }
            });

        });
        

    </script>
</body>

</html>